Repository navigation
Conversation
Contributor
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Kafka / producer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics. See unchanged results
|
Kafka / consumer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics. See unchanged results
|
This was referenced Nov 21, 2026
dougqh
force-pushed
the
dougqh/kafka-carrier-cache
branch
from
November 21, 2026 19:14
fe5dfd1 to
8131802
Compare
dougqh
force-pushed
the
dougqh/header-schema
branch
from
November 21, 2026 19:14
19ec675 to
d5708a4
Compare
An enum of the carrier keys propagators read (Datadog, W3C, baggage, B3, Haystack, X-Ray, DSM, and the forwarding / user agent / client IP headers every style reads), each with its lower-case name and ASCII bytes. Its ordinal is a dense index for per-header arrays, which keeps carrier-specific forms (a Netty AsciiString, a gRPC Metadata.Key) next to their instrumentations. CarrierKeys records the constant of every declared name that is a known header and returns it from header(String) / headerAscii(ByteBuffer), so code handling several headers can switch on it instead of comparing names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The composite propagator's cache records each key's HeaderSchema constant (IndexedCarrier.header), and passes it along: - KeyClassifier gains accept(HeaderSchema, key, value), defaulting to the by-name accept. - ContextInterpreter's implementation sends a style's own headers straight to its handling, the shared forwarding / user agent headers to their handlers, and other known headers to the common tail (client IP, header tags, mapped baggage). A null constant, header-name logging, or a style that doesn't classify the header takes the by-name path. - The Datadog and W3C interpreters classify their headers this way; the other styles keep the by-name path for now. - ExtractionCache's span id check, the single-extractor path and the baggage extractor use the constants too. A profile of a Kafka consumer had ~6% of the consumer thread's tracer time in these name comparisons (about 30 equalsIgnoreCase calls per record). ExtractorKeysForkedTest checks that, for every style and for the compound extractor, dispatching on constants extracts the same context as by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The carrier cache kept a HeaderSchema[] beside its pairs, a second reference array per extraction (about 48 bytes for the usual 8 pairs). With fewer than 127 constants, ordinal() + 1 fits in a byte, so it's a byte[] instead (24 bytes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Haystack classifies its trace / span / parent id headers like Datadog and W3C; None has no headers of its own, so every known header gets the shared handling directly. B3 and X-Ray stay by name: their accept wraps the shared handling and the common tail in its try/catch, which the generic dispatch would move outside it. ExtractorKeysForkedTest's per-style equivalence check covers the two new styles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same as CarrierKeys.contains: keys are usually lower case already, so String.equals (intrinsified, with an identity check) catches them before the case-insensitive comparison. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dougqh
force-pushed
the
dougqh/header-schema
branch
from
November 21, 2026 19:39
d5708a4 to
93a92d8
Compare
dougqh
force-pushed
the
dougqh/kafka-carrier-cache
branch
from
November 21, 2026 19:39
8131802 to
5bc558d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Adds
HeaderSchema, an enum of the headers the tracer knows by name, and dispatches extraction on those constants instead of comparing header names. Extracted contexts are unchanged.Stacked on #13606.
Motivation
A 30-minute CPU profile of a Kafka consumer had ~6% of the consumer thread's tracer time in header-name comparisons: each record's headers were compared, case-insensitively, against several names by the span id cache, the baggage extractor and the Datadog and W3C interpreters, about 30
equalsIgnoreCasecalls per record. #13605 already matches each key once against the propagators' declared names; this carries the result of that match along as a constant, so later code switches on it.Additional Notes
HeaderSchema(components/context): Datadog, W3C, baggage, B3, Haystack, X-Ray and DSM headers, plus the forwarding / user agent / client IP headers every style reads. Each constant has its lower-case name and ASCII bytes. Itsordinal()is a dense index: carrier-specific forms of a name (a NettyAsciiString, a gRPCMetadata.Key) belong in arrays indexed by ordinal next to their instrumentations, which keeps the enum dependency-free.CarrierKeysrecords the constant of every declared name that is a known header, and returns it fromheader(String)/headerAscii(ByteBuffer)(with an identity shortcut, since carriers that matched a key's bytes pass the declared name itself).IndexedCarrier.header).KeyClassifier.accept(HeaderSchema, key, value), defaulting to the by-nameaccept.ContextInterpreterimplements it: a style's own headers go straight to its handling, the shared forwarding and user agent headers to their handlers, and other known headers to the common tail (client IP, header tags, mapped baggage). A null constant, header-name logging, or a style that doesn't classify the header takes the by-name path, so the two paths can't disagree.x-amzn-trace-id, read only with AWS propagation, stays by name); None, with no headers of its own, sends every known header to the shared handling. B3 and X-Ray stay by name: theiracceptwraps the shared handling and the common tail in atry/catch, which the generic dispatch would move outside it.ExtractionCache's span id check, the single-extractor path and the baggage extractor use the constants too.HeaderSchemaTest;CarrierKeysTest/CarrierCacheTestfor constants;ExtractorKeysForkedTestchecks, for every style (with its own keys and with every known header) and for the compound Datadog + W3C extractor reading the carrier in place, that dispatching on constants extracts the same context as by name. Propagation and baggage tests pass unchanged (1,431, including the compound-extraction golden test, which goes through the composite propagator and so through the constant path).ordinal() + 1, 0 for none), not a second reference array, keeping the per-extraction cost to abyte[8].KafkaFetchedHeadersBenchmarkwithin noise (−1.4% to +2.8%, 3 forks on an 8 vCPU VM).HeaderPathBenchmarksingle-threaded on a laptop, two runs:datadog−1.6% / −0.6%,both−1.1% / 0.0%, all within run-to-run noise. An 8-thread run on the VM showeddatadog+4.4% andboth−6.9%, but neither reproduced single-threaded.equalsIgnoreCasecalls exit on identity or length, and JFR attributed some of their cost toregionMatchesCI, which never ran.byte[8]per extraction (about 24 B).🤖 Generated with Claude Code